import { defineStore } from 'pinia'
import {
  getHospitalDetailService,
  getHospitalDepartmentService
} from '@/apis/hospital'
import type {
  HospitalDdetailResponseData,
  DepartmentResponseData
} from '@/apis/hospital/type'
import { ref } from 'vue'

export const useHospitalStore = defineStore('hospital', () => {
  const hospitalInfo = ref()

  // 获取医院详情
  const getHospitalInfo = async (hoscode: string) => {
    const res: HospitalDdetailResponseData =
      await getHospitalDetailService(hoscode)
    hospitalInfo.value = res.data
  }

  // 获取科室信息
  const departmentList: any = ref([])

  // 获取科室列表
  const getDepartmentList = async (hoscode: string) => {
    const res: DepartmentResponseData =
      await getHospitalDepartmentService(hoscode)
    departmentList.value = res.data
  }

  return {
    hospitalInfo,
    getHospitalInfo,
    departmentList,
    getDepartmentList
  }
})
